package com.neudu.ssrs_yyzxservice.utils;

import com.auth0.jwt.JWT;
import com.auth0.jwt.algorithms.Algorithm;
import com.auth0.jwt.interfaces.JWTVerifier;

import java.util.Date;

public class TokenUtil {
    private static String secret = "asfasdf12";
    //生成token
    public static String getToken(){
        return JWT.create()
                .withExpiresAt(new Date(System.currentTimeMillis() + 1000 * 60 * 60 * 3))
                .sign(Algorithm.HMAC256(secret));
    }

    //获取前端传进来的token
    //验证token
    public static void authToken(String token){
        // 可以添加自逻辑
        JWTVerifier jwtVerifier = JWT.require(Algorithm.HMAC256(secret)).build();
        jwtVerifier.verify(token);
    }

}
